<?php

class LoginController extends Zend_Controller_Action
{

    public function init(){
        /* Initialize action controller here */
    }

    public function indexAction(){
      $this->view->formLogin = new Application_Form_Login();
      $this->render('index');
      $request = $this->_request;
      
      if($request->isPost()){
        $dados = $request->getPost();
        if($this->view->formLogin->isValid($dados)){
          $dados = $this->view->formLogin->getValues();
          $login = Application_Model_Login::logar($dados['login'], $dados['senha']);
          if($login == true){
            $this->_redirect('/admin');
          }else{
            echo 'erro ao logar';
          }
        }
      }
      
    }


}

